$(function(){
  $('.language').click(function(){
    if($('.box_language').css('top') == '20px'){
      $('.box_language').stop().animate({
        top:'70px',
        opacity:1
      },450);
    }
    else{
      $('.box_language').stop().animate({
        top:'20px',
        opacity:0
      },450);
    }
    $('.box_search').stop().animate({
      top:'20px',
      opacity:0
    },450);

    $('.header_phone ul').css('display','none');
    $('.header_phone .sj').css('display','none');
    event.stopPropagation();
  });

  $('.header .search').click(function(){
    if($('.box_search').css('top') == '20px'){
      $('.box_search').stop().animate({
        top:'70px',
        opacity:1
      },450);
    }
    else{
      $('.box_search').stop().animate({
        top:'20px',
        opacity:0
      },450);
    }
    
    $('.box_language').stop().animate({
      top:'20px',
      opacity:0
    },450);
    event.stopPropagation();
  });

  $('.box_language').click(function(){
    event.stopPropagation();
  });
  $('.box_search').click(function(){
    event.stopPropagation();
  });

  $('html').click(function(){
    $('.box_search').stop().animate({
      top:'20px',
      opacity:0
    },450);
    $('.box_language').stop().animate({
      top:'20px',
      opacity:0
    },450);
  });
  $('.header').click(function(){
    $('.box_search').stop().animate({
      top:'20px',
      opacity:0
    },450);
    $('.box_language').stop().animate({
      top:'20px',
      opacity:0
    },450);
  });


  $('#showSub').click(function(){
    if($('.header_phone ul').css('display') == 'none'){
      $('.header_phone ul').css('display','block');
      $('.header_phone .sj').css('display','block');
    }
    else{
      $('.header_phone ul').css('display','none');
      $('.header_phone .sj').css('display','none');
    }
    $('.box_language').stop().animate({
        top:'20px',
        opacity:0
      },450);
    event.stopPropagation();
  });
  $('html').click(function(){
    $('.header_phone ul').css('display','none');
    $('.header_phone .sj').css('display','none');
  })
  
  // 导航搜索
  $('.header .div_search img').click(function(){
    var searchText = $('.header .div_search input').val();

      var pathname = window.location.pathname;
      if(pathname =='/'){
          window.location.href = 'portal/index/search.html?text='+encodeURI(searchText);
      }else {
          window.location.href = 'search.html?text='+encodeURI(searchText);
      }

    $('.header .div_search input').val('');
  })

  // 返回顶部
  $(".scroll").click(function(){
    $("body").animate({scrollTop:0},1000);
    $('.scroll .scroll1').css('z-index',-1);
  });
  $(window).scroll(function(){
    if($(window).scrollTop()<=200)
    {
      $(".scroll").css('display','none');
    }
    else
    {
      $(".scroll").css('display','block');
    }
  });
})